package com.uroad.liaoningpos.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.uroad.liaoningpos.R;
import com.uroad.liaoningpos.common.BaseActivity;
import com.uroad.liaoningpos.model.BeondutyMDL;
import com.uroad.liaoningpos.model.OnlineMDL;
import com.uroad.lib.adapter.rv.CommonAdapter;
import com.uroad.lib.adapter.rv.ViewHolder;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @创建者 wlw
 * @创建时间 2019/4/3 20:00
 * @描述 选择班次
 */
public class SelectBeondutyInfoActivity extends BaseActivity {
    @BindView(R.id.rvStoreInfo)
    RecyclerView rvStoreInfo;
    private List<BeondutyMDL> list;
    private CommonAdapter<BeondutyMDL> adapter;
    private String type = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseContentLayoutWithoutTitle(R.layout.activity_select_store_info);
        ButterKnife.bind(this);
        setData();
    }

    private void setData() {
        final Intent intent = getIntent();
        type = intent.getStringExtra("type");
        list = (List<BeondutyMDL>) intent.getSerializableExtra("list");
        adapter = new CommonAdapter<BeondutyMDL>(this, R.layout.item_select_store_info, list) {
            @Override
            protected void convert(ViewHolder holder, final BeondutyMDL onlineMDL, int position) {
                holder.setText(R.id.tvStoreInfo, onlineMDL.getBeonduty());
                holder.setOnClickListener(R.id.tvStoreInfo, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent1 = new Intent();
                        intent1.putExtra("result", onlineMDL);
                        setResult(1001, intent1);
                        finish();
                    }
                });
            }
        };
        rvStoreInfo.setAdapter(adapter);
    }
}
